package com.example.demo.Dao;

import com.example.demo.domin.Answer;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AnswerDao extends JpaRepository<Answer,Long> {
    @Query(value = "  SELECT count(distinct student_id) FROM `fof`.`answer` WHERE `form_id`=?1 ", nativeQuery = true)
    public int getCounts(@Param("formId")Long formId);

    @Query(value = "  SELECT answer_content, COUNT(*) AS counts FROM `fof`.`answer` WHERE `form_id`=?1 GROUP BY answer_content ", nativeQuery = true)
    public List getQuestionCounts(@Param("formId")Long formId);
}
